import { createSlice,PayloadAction } from "@reduxjs/toolkit";

export type UserStateType = {
  username: string;
  nickname: string;
};

const InitState: UserStateType = { username: '', nickname: '' }

export const userSlice = createSlice({
    name: 'user',
    initialState: InitState,
    reducers: {
        loginReducer: (state: UserStateType, action: PayloadAction<UserStateType>)=>{
            return action.payload
        },
        logoutReducer: ()=>InitState
    }
})
export const { loginReducer, logoutReducer } = userSlice.actions
export default userSlice.reducer